package S08.second;

import java.util.Arrays;

import S08.second.Student.SortBy;

public class N01 {

	public static void main(String[] args) {
		Student[]a= {
				new Student("20240102", "张三", 20, 1.75, 65.5),
				new Student("20240103", "李四", 19, 1.85, 66),
				new Student("20240101", "王五", 21, 1.80, 75.5)
		};
		System.out.println("按学号对Student[]进行升序排序：");
		Arrays.sort(a);
		for (Student student : a) {
			System.out.println("   "+student);
		}

		System.out.println("按年龄对Student[]进行升序排序：");
		Arrays.sort(a, Student.sortBy(SortBy.Age)); 
		for (Student student : a) {
			System.out.println("   "+student);
		}
		
		System.out.println("按年龄对Student[]进行降序排序：");
		Arrays.sort(a, Student.sortBy(SortBy.Age).reversed()); 
		for (Student student : a) {
			System.out.println("   "+student);
		}
		
		System.out.println("按身高对Student[]进行升序排序：");
		Arrays.sort(a, (s1,s2)->Double.compare(s1.getHeight(), s2.getHeight()) ); 
		for (Student student : a) {
			System.out.println("   "+student);
		}
		
	}

}
